﻿using J.Model;
using J.ProductGet.Application.Command.AggregateCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;

namespace J.ProductGet.Controllers
{
    /// <summary>
    /// 聚合商品(读)
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AggregateCommodityController : ControllerBase
    {
        private readonly IMediator _mediator;
        public AggregateCommodityController( IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 聚合商品标签显示
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> AggregateGet(AggregateGetCommand command)
        {
            //return Ok(await _sqlSugarClient.Queryable<AggregateCommodity>().ToListAsync());
            return Ok(await _mediator.Send(command));
        }
        /// <summary>
        /// 聚合商品标签反填
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> AggregateBackil(AggregateBackilCommand command)
        {
            //return Ok(await _sqlSugarClient.Queryable<AggregateCommodity>().Where(s => s.AggregateID == AggregateID).ToListAsync());int AggregateID
            return Ok(await _mediator.Send(command));
        }
    }
}
